package sostats.core.datasource;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;

import sostats.core.help.SostatsException;

public class DbMetadataParser {
	private final Connection conn;
	final DatabaseMetaData info;
	final Configuration config;
	public DbMetadataParser(Configuration config) throws SostatsException{
		this.config = config;
		DataSource ds = config.getDataSource();
		try {
			Class.forName(ds.getDriver());
			conn = DriverManager.getConnection(ds.getUrl(), ds.getUserName(), ds.getPassword());
			info = conn.getMetaData(); 
		} catch (Exception e) {
			throw new SostatsException(e, "fail in reading metadata from db:"+config.getDataSource().toString());
		}
	}
}
